/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entityBeans;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author allankv
 */
@Entity
@Table(name = "municipality")
@NamedQueries({
    @NamedQuery(name = "Municipality.findAll", query = "SELECT m FROM Municipality m"),
    @NamedQuery(name = "Municipality.findByIdmunicipality", query = "SELECT m FROM Municipality m WHERE m.idmunicipality = :idmunicipality"),
    @NamedQuery(name = "Municipality.findByMunicipality", query = "SELECT m FROM Municipality m WHERE m.municipality = :municipality")})
public class Municipality implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idmunicipality")
    private Integer idmunicipality;
    @Column(name = "municipality")
    private String municipality;
    @OneToMany(mappedBy = "municipality", fetch = FetchType.LAZY)
    private List<Localityelement> localityelementList;

    public Municipality() {
    }

    public Municipality(Integer idmunicipality) {
        this.idmunicipality = idmunicipality;
    }

    public Municipality(Integer idmunicipality, String municipality) {
        this.idmunicipality = idmunicipality;
        this.municipality = municipality;
    }


    public Integer getIdmunicipality() {
        return idmunicipality;
    }

    public void setIdmunicipality(Integer idmunicipality) {
        this.idmunicipality = idmunicipality;
    }

    public String getMunicipality() {
        return municipality;
    }

    public void setMunicipality(String municipality) {
        this.municipality = municipality;
    }

    public List<Localityelement> getLocalityelementList() {
        return localityelementList;
    }

    public void setLocalityelementList(List<Localityelement> localityelementList) {
        this.localityelementList = localityelementList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idmunicipality != null ? idmunicipality.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Municipality)) {
            return false;
        }
        Municipality other = (Municipality) object;
        if ((this.idmunicipality == null && other.idmunicipality != null) || (this.idmunicipality != null && !this.idmunicipality.equals(other.idmunicipality))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entityBeans.Municipality[idmunicipality=" + idmunicipality + "]";
    }

}
